<style>table.table-data{border:none} table.table-data .col-cmpa{width:100px} table.table-data .col-cmpb{width:100px}div#table-compare{position:relative;border: 1px solid #dedede}div#table-compare div#scroll-height{overflow:auto;margin-top:0px}table.table-data.scrollpage tr.header{position:absolute;width:100%;top:0px;left:0px}table.table-data.scrollpage tbody{position:absolute;width:100%;overflow:auto}</style>
<div id="scroll-height">
<table class="table-data scrollpage">
    <thead>
    <tr class="header">
        <th class="col-date">Date</th>
        <th class="col-cmpa"><p style="width: 100px; word-wrap:break-word;margin: 0"><?php echo isset($companyA)?$companyA:""; ?></p></th>
        <th class="col-cmpb"><p style="width: 100px; word-wrap:break-word;margin: 0"><?php echo isset($companyB)?$companyB:""; ?></p></th>
        <th class="col-ratio">Ratio</th>
        <th class="col-stddev">STD Dev</th>
        <th class="col-meanra">Mean(Ra)</th>
        <th class="col-sdmean">SD-Mean</th>
        <th class="col-signal">Signal</th>
        <th class="col-spread">Spread</th>
    </tr>
    </thead>
    <tbody>
    <?php
        $arrClass = array('col-date', 'col-cmpa', 'col-cmpb', 'col-ratio', 'col-stddev', 'col-meanra', 'col-sdmean', 'col-signal', 'col-spread');
        if(isset($arrCmp)) { 
            for ($i = 0; $i < count($arrCmp); $i++) {
    			$rowClass = ($i%2==0?'even':'odd');
                echo "<tr class='row ".$rowClass."'>";
    			for ($j = 0; $j < count($arrCmp[0]); $j++) {
    				if (isset($arrCmp[$i][$j])) {
    				    echo "<td class='" . $arrClass[$j] . "'>" . trim($arrCmp[$i][$j]!=''?$arrCmp[$i][$j]:'-') . '</td>';
    				} else {
    					echo "<td class='" . $arrClass[$j] . "'>" . "-" . '</td>';
    				}
    			}
    			echo '</tr>';
    		}
        }
    ?>
    </tbody>
</table>
</div>
<script type="text/javascript">
    $(document).ready(function(){
        $('p#table-title').html('<?php echo isset($companyA)?$companyA:""; ?> <span>vs</span> <?php echo isset($companyB)?$companyB:""; ?>').fadeIn();
        var curTHSignal = $('table.table-data tr.header th.col-signal');
        var curTDSignal = $('table.table-data tr.row:first td.col-signal');
        $('div#table-compare div#scroll-height').height(<?php echo TABLE_COMPARE_HEIGHT; ?>);
        $('table.table-data tbody').height(<?php echo TABLE_COMPARE_HEIGHT; ?> - curTHSignal.height() - 16).css({'top':curTHSignal.height() + 17});
        if(curTDSignal.width() < curTHSignal.width()){curTDSignal.width(curTHSignal.width());}else{curTHSignal.width(curTDSignal.width());}
    });
</script>